<template>
  <div class="app-container">
    <div class="filter-container">
      <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="getData">
        刷新
      </el-button>
    </div>
    <el-table
      :key="tableKey"
      v-loading="listLoading"
      :data="tableData"
      border
      fit
      highlight-current-row
      style="width: 100%;"
    >
      <el-table-column label="渠道ID" align="center" prop="channelId"/>
      <el-table-column label="渠道名称" align="center" prop="channelName"/>
      <el-table-column label="单价" align="center" prop="channelPrice" />
      <el-table-column label="渠道UV" align="center" prop="channelUV"/>
      <el-table-column label="实际注册数" align="center" prop="channelRegNum"/>
      <el-table-column label="成本消耗" align="center" prop="cost"/>
      <el-table-column label="总收入" align="center" prop="totalIncome" />
      <el-table-column label="产值单价" align="center" prop="outputValue"/>
      <el-table-column label="返消耗收益" align="center" prop="returnPrice"/>
      <el-table-column label="返回注册数" align="center" prop="returnRegNum"/>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="listQuery.pageNum"
      :limit.sync="listQuery.pageSize"
      @pagination="getData"
    />
  </div>
</template>

<script>
import { aList } from '@/api/channel'
import waves from '@/directive/waves' // waves directive
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
export default {
  name: 'Phonelist',
  components: { Pagination },
  directives: { waves },
  data() {
    return {
      tableData: [],
      total: 0,
      tableKey: 0,
      listQuery: {
        pageNum: 1,
        pageSize: 10
      },
      listLoading: false
    }
  },
  created() {
    this.getData()
  },
  methods: {
    getData(){
      this.listLoading = true
      aList(this.listQuery).then( res => {
        this.listLoading = false
        if( res.data.code == '200' ){
          this.tableData = res.data.data.records;
          this.total = res.data.data.total
        } else {
          this.$message.error(res.data.msg);
        }
      })
    }
  }
}
</script>

<style scoped>

</style>
